home *** CD-ROM | disk | FTP | other *** search
/ Aminet 33 / Aminet 33 - October 1999.iso / Aminet / dev / c / C_Keywords.lha / C_Keywords.doc.src < prev    next >
Encoding:
Text File  |  1999-05-13  |  84.1 KB  |  2,311 lines

  1. /****** /auto ********************************************************
  2. *
  3. *   NAME
  4. *      auto - Is an access modifier which declares variables to be
  5. *             local.
  6. *
  7. *   SYNOPSIS
  8. *      auto <datatype> <variable list>;
  9. *
  10. *   FUNCTION
  11. *      Auto declares variables to be local.  It is almost never used
  12. *      by anyone.  It exists only because it was part of the original
  13. *      C set of keywords.  To declare a local variable all you need to
  14. *      do is to declare it inside the code block that you intend to
  15. *      use it in.  A code block begins at the start of a curly brace
  16. *      "{" and ends with another curly brace "}".
  17. *
  18. *   INPUTS
  19. *      <datatype> - A basic C type or a user defined (complex) type.
  20. *      <variable list> - A list of variables separated by commas.
  21. *
  22. *   RESULT
  23. *      none.
  24. *
  25. *   EXAMPLE
  26. *      auto int x, y, z = 25;
  27. *
  28. *   NOTES
  29. *      Never use, it just doesn't look very professional.
  30. *
  31. *   BUGS
  32. *      none. - If there are, there is something really wrong with your
  33. *              compiler;-)
  34. *
  35. *   SEE ALSO
  36. *      extern, static, register.
  37. *
  38. *      void, char, int, float, double,
  39. *      long, short, signed, unsigned,
  40. *      const, volatile.
  41. *
  42. *********************************************************************/
  43.  
  44. /****** /break *******************************************************
  45. *
  46. *   NAME
  47. *      break - Used either as a part of a switch statement, or to
  48. *              prematurely break out of a loop.
  49. *
  50. *   SYNOPSIS
  51. *      switch (<var>)
  52. *      {
  53. *         case <const1>:
  54. *            <statement sequence>;
  55. *            break;
  56. *         case <const2>:
  57. *            <statement sequence>;
  58. *            break;
  59. *         default:
  60. *            <statement sequence>;
  61. *      }
  62. *
  63. *      or
  64. *
  65. *      while (<var>==0)
  66. *      {
  67. *         if (<var>==0) break;
  68. *         printf("This text will not be printed\n");
  69. *      }
  70. *
  71. *
  72. *   FUNCTION
  73. *      This C keyword will prematurely break you out of a looping
  74. *      structure or can be used to terminate a statement sequence
  75. *      after a case statement.  In this last role it is optional
  76. *      but is almost always used unless there is a specific reason
  77. *      not to.
  78. *
  79. *   INPUTS
  80. *      none.
  81. *
  82. *   RESULT
  83. *      none.
  84. *
  85. *   EXAMPLE
  86. *      switch (x)
  87. *      {
  88. *         case 1:
  89. *            printf("x is equal to 1.\n");
  90. *            break;
  91. *         case 2:
  92. *            printf("x is equal to 2\n");
  93. *            printf("and it is not equal to 1.\n");
  94. *            break;
  95. *         default:
  96. *            printf("x is not equal to 1 or 2\n");
  97. *            printf("it must be something else then.\n");
  98. *      }
  99. *
  100. *      or
  101. *
  102. *      while (x==0)
  103. *      {
  104. *         if (x==0) break;
  105. *         printf("This text will not be printed\n");
  106. *      }
  107. *
  108. *   NOTES
  109. *      Switch statements do not require the break statement, but
  110. *      in most instances you will want to use break.  An example
  111. *      of when you wouldn't want to use break would be if you
  112. *      wanted the first case <statement sequence> to execute and
  113. *      also the second <statement sequence> if the first is called
  114. *      but only the second if the second case is called.
  115. *
  116. *   BUGS
  117. *      none - If you're even considering that break might have a
  118. *             bug, maybe you should either rethink the problem, or
  119. *             invest in an expensive compiler, only to find that
  120. *             the problem is still there.
  121. *
  122. *   SEE ALSO
  123. *      switch, continue.
  124. *      case, for, while, do.
  125. *
  126. *********************************************************************/
  127.  
  128. /****** /case ********************************************************
  129. *
  130. *   NAME
  131. *      case - Used with the switch statement
  132. *
  133. *   SYNOPSIS
  134. *      case <const>: <statement sequence>;
  135. *
  136. *   FUNCTION
  137. *      Case is used with the switch statement and can be considered
  138. *      to be part of the switch statement as "do" is associated with
  139. *      a "do while" loop.
  140. *
  141. *   INPUTS
  142. *      <const> - Any integer constant, can be either declared with
  143. *                the "const" keyword or simply typed in directly as
  144. *                an integer number.  Character constants and
  145. *                enumerations may be used also.
  146. *      <statement sequence> - The single statement or block of
  147. *                             statements which is/are to be executed
  148. *                             by default.
  149. *
  150. *   RESULT
  151. *      none.
  152. *
  153. *   EXAMPLE
  154. *      switch (x)
  155. *      {
  156. *         case 1:
  157. *            printf("x is equal to 1.\n");
  158. *            break;
  159. *         case 2:
  160. *            printf("x is equal to 2\n");
  161. *            printf("and it is not equal to 1.\n");
  162. *            break;
  163. *         default:
  164. *            printf("x is not equal to 1 or 2\n");
  165. *            printf("it must be something else then.\n");
  166. *      }
  167. *
  168. *   NOTES
  169. *      It should be noted that in a switch statement any constant of
  170. *      type char, (or any other type other than an int), will first
  171. *      be converted to an integer.  This doesn't really matter as
  172. *      far as the programmer is concerned unless the variable type
  173. *      is larger than an integer, in which case the value will get
  174. *      garbled and the program will behave in a way which was
  175. *      unintended.  The reason switch will only handle integral types
  176. *      is for speed reasons.
  177. *
  178. *   BUGS
  179. *      As stated above, only works with types smaller or equal in
  180. *      size to integers.
  181. *
  182. *   SEE ALSO
  183. *      switch, break, const, int, char.
  184. *
  185. *********************************************************************/
  186.  
  187. /****** /char ********************************************************
  188. *
  189. *   NAME
  190. *      char - Is a data type which declares a variable of type char.
  191. *
  192. *   SYNOPSIS
  193. *      char <variable list>;
  194. *
  195. *   FUNCTION
  196. *      Char declares a variable of type char, meaning that the
  197. *      variable will hold a single ASCII character.  Technically
  198. *      type char is an 8 bit type that will hold any number between
  199. *      -128 and 127.  Often operating systems will declare their own
  200. *      variable types and will usually have one called BYTE or UBYTE
  201. *      or the like which is either a char or unsigned char.
  202. *
  203. *   INPUTS
  204. *      <variable list> - A list of the variables you are declaring,
  205. *                        separated by commas.
  206. *
  207. *   RESULT
  208. *      none.
  209. *
  210. *   EXAMPLE
  211. *      char x, y = 'a', z[257] = "This is a string of characters";
  212. *
  213. *   NOTES
  214. *      To store a string of characters in a variable,
  215. *      (i.e. Hello there) you make an array of characters and store
  216. *      each letter in one element of that array.  The declaration
  217. *      would look like this, (char thsisastrn[257];)  You could
  218. *      then store a sentence of up to 256 characters in length.
  219. *      Also I'd like to mention that there is a w_char type that isn't
  220. *      a built in C type but is defined in one of the standard headers
  221. *      and can be used to store characters for languages besides
  222. *      english and the like.  I believe that w_char is usually used
  223. *      for unicode, but I'm not really sure about the details.  If
  224. *      your interested in making your programs portable to other
  225. *      countries and cultures then check it out.  Also it should be
  226. *      noted that in C++ w_char is a built in type.
  227. *
  228. *   BUGS
  229. *      none. - Man, if you've got bugs with this, you've got some
  230. *              serious problems!!!
  231. *
  232. *   SEE ALSO
  233. *      void, int, float, double.
  234. *
  235. *      long, short, signed, unsigned,
  236. *      const, volatile,
  237. *      extern, static, register, auto,
  238. *      struct, union, typedef, enum.
  239. *
  240. *********************************************************************/
  241.  
  242. /****** /const *******************************************************
  243. *
  244. *   NAME
  245. *      const - Is an access modifier which is used to declare a
  246. *              special "constant" variable type.
  247. *
  248. *   SYNOPSIS
  249. *      const <datatype> <name> = <expression>, <name> = <expression>,
  250. *      etc, etc;
  251. *
  252. *   FUNCTION
  253. *      Const declares and initializes variables which cannot be
  254. *      altered by the program after initialization.  The declaration
  255. *      looks the same as a normal variable declaration with the
  256. *      exception that the "const" keyword precedes it, and each
  257. *      constant must be initialized at the time it is declared, (i.e.
  258. *      given a value such as x = 25).  An example of a practical use
  259. *      would be to make PI a const float equal to 3.14...
  260. *
  261. *   INPUTS
  262. *      <datatype> - A basic C datatype, (i.e. char, int, float, double),
  263. *                   or a user defined (complex) data type.
  264. *      <name> - Name of the constant being declared.
  265. *      <expression> - Any "statement" which evaluates to  the
  266. *                     declared type, (i.e. For type int, 25 would be
  267. *                     acceptable).
  268. *
  269. *   RESULT
  270. *      none.
  271. *
  272. *   EXAMPLE
  273. *      const float PI = 3.14, e_raised2_x = 2.71828;
  274. *
  275. *   NOTES
  276. *      While const types may not be altered by the program, they may
  277. *      be altered by some hardware dependent means.  A good example of
  278. *      this would be to store the address of a place in memory that
  279. *      always contains the current time in a constant pointer that
  280. *      your program can't alter, but can look at whenever it wants
  281. *      to know the time.  Honestly a technique like this might make
  282. *      more sense in C++ where you can declare variable in the middle
  283. *      of your code.  Also in this example you should probably use
  284. *      the keyword volatile to keep the compiler from doing any
  285. *      optimizations that would cause flaky results.  I was really
  286. *      just giving it as a for instance so you can take it or leave
  287. *      it.  Also, the word "constant" refers to both the special type
  288. *      and any fixed value in the program,
  289. *      (i.e. 25+25 or "Hello world\n").  The reason for this is that
  290. *      from the compiler's point of view they are stored in the same
  291. *      way.  Also, you can think of it from the standpoint that 25+25
  292. *      is a constant expression because the answer will always be 50.
  293. *      In many cases, (OK ALL CASES), you may use a #define
  294. *      preprocessor directive in place of the const variable type.
  295. *      It should be noted, however, that #define works in a different
  296. *      manner than const does, (at least from the compilers point of
  297. *      view.)
  298. *
  299. *   BUGS
  300. *      none.
  301. *
  302. *   SEE ALSO
  303. *      volatile, #define.
  304. *      void, char, int, float, double,
  305. *      long, short, signed, unsigned.
  306. *
  307. *      extern, static, register, auto,
  308. *      struct, union, typedef, enum.
  309. *
  310. *********************************************************************/
  311.  
  312. /****** /continue ****************************************************
  313. *
  314. *   NAME
  315. *      continue - Used in a loop to force the next iteration, (cycle),
  316. *                 immediately.
  317. *
  318. *   SYNOPSIS
  319. *      for (<var>=0; <var><100; <var>++)
  320. *      {
  321. *         if (<var>>=50) continue;
  322. *         printf("%d\n", <var>);
  323. *      }
  324. *
  325. *   FUNCTION
  326. *      Continue is used to force the next iteration of a looping
  327. *      structure, (i.e. for, while, do while).  Continue is used in
  328. *      much the same manner as the break statement, except that
  329. *      instead of breaking completely out of the loop, it just causes
  330. *      the loop to skip to the end, and then start on the next
  331. *      iteration.  In the examples for instance, only the numbers
  332. *      0-49 are printed even though the loop is executed and the <var>
  333. *      is incremented 100 times.
  334. *
  335. *   INPUTS
  336. *      none.
  337. *
  338. *   RESULT
  339. *      none.
  340. *
  341. *   EXAMPLE
  342. *      for (x = 0; x<100; x++)
  343. *      {
  344. *         if( x>=50) continue;
  345. *         printf("%d\n", x);
  346. *      }
  347. *
  348. *   NOTES
  349. *      When continue is used in a for loop, the variable is
  350. *      incremented, then the conditional statement is tested, then the
  351. *      loop starts again.  This is the same action which would take
  352. *      place if the end of the code block had been reached.  In
  353. *      "while" and "do while", only the conditional statement is
  354. *      evaluated, (as they do not have the built in ability to
  355. *      increment variables), and then the loop starts again.
  356. *
  357. *   BUGS
  358. *      none.
  359. *
  360. *   SEE ALSO
  361. *      break.
  362. *      for, while, do.
  363. *
  364. *********************************************************************/
  365.  
  366. /****** /default *****************************************************
  367. *
  368. *   NAME
  369. *      default - Used in conjunction with the switch statement to
  370. *                specify a default course of action.
  371. *
  372. *   SYNOPSIS
  373. *      default: <statement sequence>;
  374. *
  375. *   FUNCTION
  376. *      Default is used in conjunction with the switch statement to
  377. *      specify a default course of action when no case statements
  378. *      have been matched.  In essence, it is to switch, what else is
  379. *      to if.
  380. *
  381. *   INPUTS
  382. *      <statement sequence> - The single statement or block of
  383. *                             statements which is/are to be executed
  384. *                             by default.
  385. *
  386. *   RESULT
  387. *      none.
  388. *
  389. *   EXAMPLE
  390. *      switch (x)
  391. *      {
  392. *         case 1:
  393. *            printf("x is equal to 1.\n");
  394. *            break;
  395. *         case 2:
  396. *            printf("x is equal to 2\n");
  397. *            printf("and it is not equal to 1.\n");
  398. *            break;
  399. *         default:
  400. *            printf("x is not equal to 1 or 2\n");
  401. *            printf("it must be something else then.\n");
  402. *      }
  403. *
  404. *   NOTES
  405. *      none.
  406. *
  407. *   BUGS
  408. *      none.
  409. *
  410. *   SEE ALSO
  411. *      switch, case.
  412. *
  413. *********************************************************************/
  414.  
  415. /****** /do **********************************************************
  416. *
  417. *   NAME
  418. *      do - Part of the "do while" looping construct.
  419. *
  420. *   SYNOPSIS
  421. *      do
  422. *      {
  423. *         <statement sequence>;
  424. *      } while (<conditional statement>);
  425. *
  426. *   FUNCTION
  427. *      Do is used to start a "do while" loop.  A "do while" loop
  428. *      behaves in almost the same manner as a while loop, with the
  429. *      exception that the <statement sequence> is executed before
  430. *      the <conditional statement>.  This has the effect that the
  431. *      loop always executes at least once regardless of whether the
  432. *      <conditional statement> is true or false.
  433. *
  434. *   INPUTS
  435. *      <statement sequence> - The single statement or block of
  436. *                             statements which is/are to be executed.
  437. *      <conditional statement> - A statement which evaluates to either
  438. *                                true or false.  False is equal to 0
  439. *                                and true is anything else, however
  440. *                                it is common practice to have -1 or 1
  441. *                                represent true.
  442. *
  443. *   RESULT
  444. *      none.
  445. *
  446. *   EXAMPLE
  447. *      do
  448. *      {
  449. *         printf("Enter a number between 1 & 5...\n");
  450. *         scanf("%d", &x);
  451. *      } while ((x<1) || (x>5));
  452. *
  453. *   NOTES
  454. *      In the example above the loop reads in x from the user and then
  455. *      tests to see if that value is acceptable.  A "while" loop could
  456. *      not have been used effectively because x could have been set to
  457. *      anything, including a value which would have caused the
  458. *      program to skip the loop entirely.  You could conceivably
  459. *      set x to zero before you enter a "while" loop, but it is
  460. *      easier and more readable simply to use "do while".  Nuff said.
  461. *
  462. *   BUGS
  463. *      none.
  464. *
  465. *   SEE ALSO
  466. *      while, for.
  467. *      if, switch.
  468. *
  469. *********************************************************************/
  470.  
  471. /****** /double ******************************************************
  472. *
  473. *   NAME
  474. *      double - Is a data type and keyword used to declare variables
  475. *               which hold double precision floating point values.
  476. *
  477. *   SYNOPSIS
  478. *      double <variable list>;
  479. *
  480. *   FUNCTION
  481. *      Double declares variables that can be used to store double
  482. *      precision floating point numbers.  A double precision number
  483. *      is 64 bits wide in memory, meaning that the number can
  484. *      range from -1.7e-308 to 1.7e308.  It should be noted that
  485. *      unlike int, but like float, the double type can be used to
  486. *      store fractional numbers which are extremely small or extremely
  487. *      large.  Double should be used when variables of type float are
  488. *      too small to hold the desired number or when extreme accuracy
  489. *      in calculations is needed.
  490. *
  491. *   INPUTS
  492. *      <variable list> - A list of the variables you are declaring,
  493. *                        separated by commas.
  494. *
  495. *   RESULT
  496. *      none.
  497. *
  498. *   EXAMPLE
  499. *      double x, y, z = 3.14;
  500. *
  501. *   NOTES
  502. *      In older versions of C, double was a synonym for long float.
  503. *      As per the ANSI standard, long float is no longer accepted and
  504. *      the double keyword must be used.  Both float and double require
  505. *      more space and more CPU time to do calculations on than do
  506. *      ints.  Try to avoid using them inside of loops that are crucial
  507. *      to the speed of the program.  Instead try to put them in places
  508. *      where the expression in question only gets executed every now
  509. *      and then, and not 100 times a second.  There is a way to do
  510. *      division on ints so that the remainder is known.  This is much
  511. *      faster and more information is available, (see div).  Many
  512. *      times you must link a special library to your code to do
  513. *      floating point math, (i.e. to be able to use floats and
  514. *      doubles).  This is because they are so much slower and most
  515. *      programmers try to avoid them except in special cases.  It is
  516. *      also because there are different ways for the compiler to do
  517. *      the math internally.  If you have an FPU for example, you can
  518. *      compile your code to take advantage of that special hardware by
  519. *      linking it to a library that supports an FPU, or you can link
  520. *      to a generic library, (mieee library for example), and all of
  521. *      the calculations will be preformed by the software, with the
  522. *      effect that your program will run on computers that aren't
  523. *      lucky enough to have an FPU, (like my computer for example).
  524. *      If in doubt, use mieee, it's safer.  When I speak of libraries
  525. *      it should be noted that I am talking about link libraries which
  526. *      come with your compiler and not the amigados shared libraries
  527. *      which reside in the libs: assign.
  528. *
  529. *   BUGS
  530. *      Slow.
  531. *
  532. *   SEE ALSO
  533. *      void, int, char, double.
  534. *
  535. *      long, short, signed, unsigned,
  536. *      const, volatile,
  537. *      extern, static, register, auto,
  538. *      struct, union, typedef, enum.
  539. *
  540. *********************************************************************/
  541.  
  542. /****** /else ********************************************************
  543. *
  544. *   NAME
  545. *      else - Part of the if statement which specifies a default
  546. *             course of action, (OPTIONAL).
  547. *
  548. *   SYNOPSIS
  549. *      if (<conditional statement>)
  550. *      {
  551. *         <statement sequence>;
  552. *      }
  553. *      else
  554. *      {
  555. *         <statement sequence>;
  556. *      }
  557. *
  558. *   FUNCTION
  559. *      Else specifies a default course of action to take when the
  560. *      <conditional statement> evaluates to false.  If it evaluates
  561. *      to true then else is skipped.
  562. *
  563. *   INPUTS
  564. *      <conditional statement> - A statement which evaluates to either
  565. *                                true or false.  False is equal to 0
  566. *                                and true is anything else, however
  567. *                                it is common practice to have -1 or 1
  568. *                                represent true.
  569. *      <statement sequence> - The single statement or block of
  570. *                             statements which is/are to be executed
  571. *                             by default.
  572. *
  573. *   RESULT
  574. *      none.
  575. *
  576. *   EXAMPLE
  577. *      if (x)
  578. *      {
  579. *         printf("x is unequal to zero.\n");
  580. *      }
  581. *      else
  582. *      {
  583. *         printf("x is 0.\n");
  584. *      }
  585. *
  586. *   NOTES
  587. *      Else can be used in a couple of ways.  It can be used as shown
  588. *      above to produce an either or type of decision or can be used
  589. *      to string together several ifs, (i.e.
  590. *
  591. *      if (x==0) {<statement sequence>;}
  592. *      else if (x<0) {<statement sequence>;}
  593. *      else if (x>0) {<statement sequence>;}).
  594. *
  595. *      You could just use 3 ifs in this situation, however the
  596. *      "if else if ladder" executes faster because if the first
  597. *      expression is met then the rest are skipped by default and
  598. *      don't waste time evaluating to false.
  599. *
  600. *   BUGS
  601. *      none.
  602. *
  603. *   SEE ALSO
  604. *      if, switch.
  605. *      for, while, do.
  606. *
  607. *********************************************************************/
  608.  
  609. /****** /enum ********************************************************
  610. *
  611. *   NAME
  612. *      enum - Defines an enumeration data type, and is used to declare
  613. *             variables of that type.
  614. *
  615. *   SYNOPSIS
  616. *      enum <tagname> {<enumeration list>} <variable list>;
  617. *
  618. *   FUNCTION
  619. *      Enum defines a new data type, much the same way struct and
  620. *      union do.  These new data types that the user creates are
  621. *      often referred to as "user defined types".  Enum is also used
  622. *      in the declaration of variables that are to be of a type
  623. *      which was defined using enum.  Enum really can't be
  624. *      explained without an example so we'll refer to the example
  625. *      below.  "coins" is the new data type.  "money" is a global
  626. *      variable of type coins.  "moremoney" is a local variable of
  627. *      type coins.  Now that we have our two variables "money" and
  628. *      "moremoney" we can assign them a value of type coins, (i.e.
  629. *      any of {penny, nickel, dime, or quarter}.  Conditional tests
  630. *      may be performed on "money" and "moremoney".  We used switch
  631. *      below, but you may use if statements, while, for, do while,
  632. *      or any other C construct that allows conditional (true/false)
  633. *      tests.  I think if you look over the example, you'll get the
  634. *      idea of what enumerations are good for.
  635. *
  636. *   INPUTS
  637. *      <tagname> - The name of the variable type being created, (i.e.
  638. *                  you would use this name when declaring variables
  639. *                  of this type.
  640. *      <enumeration list> - The list of enumeration names that will
  641. *                           be used as the "pseudo data" for any
  642. *                           variable being declared as type <tagname>.
  643. *      <variable list> - A list of the variables you would like to
  644. *                        declare separated by commas.  This allows
  645. *                        variables to be declared at the same time
  646. *                        the data type is defined.
  647. *
  648. *   RESULT
  649. *      none.
  650. *
  651. *   EXAMPLE
  652. *      enum coins {penny, nickel, dime, quarter} money;
  653. *
  654. *      int main(void)
  655. *      {
  656. *         enum coins moremoney;
  657. *
  658. *         money = penny;
  659. *         moremoney = dime;
  660. *
  661. *         switch (money)
  662. *         {
  663. *            case penny: printf("Hey I've got a penny.\n");
  664. *            break;
  665. *            case nickel: printf("Hey I've got a nickle.\n");
  666. *            break;
  667. *            case dime: printf("Hey I've got a dime.\n");
  668. *            break;
  669. *            case quarter: printf("Hey I've got a quarter.\n");
  670. *         }
  671. *
  672. *         switch (moremoney)
  673. *         {
  674. *            case penny: printf("Hey, I've got another penny.\n");
  675. *            break;
  676. *            case nickel: printf("Hey, I've got another nickel.\n");
  677. *            break;
  678. *            case dime: printf("Hey, I've got another dime.\n");
  679. *            break;
  680. *            case quarter: printf("Hey, I've got another quarter.\n");
  681. *         }
  682. *
  683. *         exit(0);
  684. *      }
  685. *
  686. *
  687. *   NOTES
  688. *      It should be noted that enum is just a fancy way of disguising
  689. *      the int variable type.  In the example above "money = penny" is
  690. *      equivalent to "money = 0", and "moremoney = dime" is equal to
  691. *      "moremoney = 2".  The <enumeration list> assigns the different
  692. *      names integer values beginning with 0 and going up by one, (i.e.
  693. *      1, 2, 3, 4, 5, 6, etc).  You can alter this pattern by using
  694. *      an assignment in the definition, (i.e.  enum coins {penny = 0,
  695. *      nickel = 5, dime = 10, quarter = 25}.  By doing this you could
  696. *      create tests like ( if (nickle+nickle==dime) printf("2 nickels
  697. *      equals 1 dime.");).  You can even assign two names the same
  698. *      value, (i.e. enum coins {penny, nickel, dime, quarter,
  699. *      two_bits = 3, half_dollar}.  In this situation penny = 0,
  700. *      nickel = 1, dime = 2, quarter = 3, two_bits = 3, and
  701. *      half_dollar = 4.
  702. *
  703. *   BUGS
  704. *      Any restrictions that would apply to type int, also apply to
  705. *      enums, on the other hand any advantages that ints have over
  706. *      other types also apply to enums.  This is why enumerations
  707. *      work with the switch statement so well.
  708. *
  709. *   SEE ALSO
  710. *      struct, union, typedef.
  711. *
  712. *      switch, if,
  713. *      for, while, do.
  714. *
  715. *********************************************************************/
  716.  
  717. /****** /extern ******************************************************
  718. *
  719. *   NAME
  720. *      extern - Is an access modifier used in variable declarations
  721. *               to specify that the variable is declared in another
  722. *               source file which will be linked later.
  723. *
  724. *   SYNOPSIS
  725. *      extern <data type> <variable list>;
  726. *
  727. *   FUNCTION
  728. *      Extern is used in variable declarations to specify that the
  729. *      variable is declared in another source file which will be
  730. *      linked later.  It isn't a definition per say, but merely lets
  731. *      the compiler know that the variable is out there.  If you don't
  732. *      tell the compiler that the variable is declared elsewhere
  733. *      then it will most likely spit up an "unknown identifier" error,
  734. *      and if you don't use the extern keyword then the linker will
  735. *      spit out a "multiply declared identifier" error or something
  736. *      like that.  Basically, a program can't define something
  737. *      twice, so you have to use extern to tell the compiler that even
  738. *      though this variable hasn't been declared yet, it can still go
  739. *      ahead and compile the proggy just as if it had been declared.
  740. *
  741. *   INPUTS
  742. *      <data type> - Is any one of C's built in data types like: int,
  743. *                    char, float, double, etc.  Also you may use your
  744. *                    own user defined (complex) data types,
  745. *                    (i.e., structs, unions, etc).
  746. *      <variable list> - Is a list of variables that have been
  747. *                        declared elsewhere, separated by commas.  see
  748. *                        the example for clarification.
  749. *
  750. *   RESULT
  751. *      none.
  752. *
  753. *   EXAMPLE
  754. *      /* sourcenumber1.c */
  755. *      void testfunction(void);
  756. *
  757. *      int x, y = 2, z[50] = {0};
  758. *
  759. *      int main(void)
  760. *      {
  761. *         testfunction();
  762. *
  763. *         return 0;
  764. *      }
  765. *
  766. *      /* sourcenumber2.c */
  767. *      extern int x, y, z[50];
  768. *
  769. *      void testfunction(void)
  770. *      {
  771. *         printf("%d, %d, %d\n", x, y, z[0]);
  772. *      }
  773. *
  774. *   NOTES
  775. *      The example above is cut up into two source files.  Something
  776. *      to note about using extern is that it only makes sense to use
  777. *      it when dealing with multiple source code files.  Also notice
  778. *      how the arrays were handled.  Typically I like to declare
  779. *      something as external exactly the same way I declared it
  780. *      originally, (but without the initialization).  In the second
  781. *      source file I could just as easily have written,
  782. *      (extern x, y, z[];).  Stick to whatever makes the most sense
  783. *      to you, I just find it easier to mimic the original form as
  784. *      it's less semantic bs to remember and I think it aids in
  785. *      readability.
  786. *
  787. *   BUGS
  788. *      I certainly hope not!!!
  789. *
  790. *   SEE ALSO
  791. *      volatile, register,
  792. *      const, signed, unsigned, short, long.
  793. *
  794. *
  795. *********************************************************************/
  796.  
  797. /****** /float *******************************************************
  798. *
  799. *   NAME
  800. *      float - Is a data type used for holding floating point numbers
  801. *              between -3.4e38 and 3.4e38.
  802. *
  803. *   SYNOPSIS
  804. *      float <variable list>;
  805. *
  806. *   FUNCTION
  807. *      float is a data type used for holding floating point numbers
  808. *      between -3.4e38 and 3.4e38.  A floating point number takes more
  809. *      time for the computer to do calculations on than int.  It is
  810. *      always preferable to use int if you can use one type or the
  811. *      other however there are just some spots that you can't get out
  812. *      of using floating point numbers.  Floating point numbers are
  813. *      useful in two common happenstances: one, the number being
  814. *      stored is of exceptional accuracy, (like .000231), and
  815. *      maintaining that accuracy is crucial, or two, if the number is
  816. *      too large to store in an int or a long int,
  817. *      (like 3.2861 * 10^28).
  818. *
  819. *   INPUTS
  820. *      <variable list> - A list of the variables being declared
  821. *                        separated by commas.
  822. *
  823. *   RESULT
  824. *      none.
  825. *
  826. *   EXAMPLE
  827. *      float x, y = 3.14, z[5] = {2.2, 3.3, 4.4, 5.5, 6.6};
  828. *
  829. *   NOTES
  830. *      When you do decide you need floats, try to avoid using them
  831. *      inside of loops that that are crucial to the speed of the
  832. *      program.  Instead try to put them in places where the
  833. *      expression in question only gets executed every now and then,
  834. *      and not 100 times in a second.  There is a way to do
  835. *      division on ints so that the remainder is known.  This is much
  836. *      faster and more information is available, (see div).  Many
  837. *      times you must link a special library to your code to do
  838. *      floating point math, (i.e. to be able to use floats and
  839. *      doubles).  This is because they are so much slower and most
  840. *      programmers try to avoid them except in special cases.  It is
  841. *      also because there are different ways for the compiler to do
  842. *      the math internally.  If you have an FPU for example, you can
  843. *      compile your code to take advantage of that special hardware by
  844. *      linking it to a library that supports an FPU, or you can link
  845. *      to a generic library, (mieee library for example), and all of
  846. *      the calculations will be preformed by the software, with the
  847. *      effect that your program will run on computers that aren't
  848. *      lucky enough to have an FPU, (like my computer for example).
  849. *      If in doubt, use mieee, it's safer.  When I speak of libraries
  850. *      it should be noted that I am talking about link libraries which
  851. *      come with your compiler and not the amigados shared libraries
  852. *      which reside in the libs: assign.
  853. *
  854. *   BUGS
  855. *      Contact the manufacturer of your compiler on this one, they've
  856. *      obviously been exposed to too many drugs in the 60's.
  857. *
  858. *   SEE ALSO
  859. *      void, int, char, double.
  860. *
  861. *      long, short, signed, unsigned,
  862. *      const, volatile,
  863. *      extern, static, register, auto,
  864. *      struct, union, typedef, enum.
  865. *
  866. *********************************************************************/
  867.  
  868. /****** /for *********************************************************
  869. *
  870. *   NAME
  871. *      for - The C keyword used for constructing, (most notably), a
  872. *            for loop.  The for keyword is very versatile however, and
  873. *            can be used to construct different kinds of loops,
  874. *            (like infinite loops, and pseudo while loops).
  875. *
  876. *   SYNOPSIS
  877. *      for (<variable assignments>; <test conditions>; <statements>)
  878. *      {
  879. *         <statement sequence>;
  880. *      }
  881. *
  882. *   FUNCTION
  883. *      The for loop is useful for keeping track of how many iterations
  884. *      have gone by during an operation, and also to terminate based
  885. *      on either the number iterations, or on some other unrelated
  886. *      criteria.  C for loops have much more bite to them then other
  887. *      languages.  A for loop is really just a while loop with added
  888. *      capabilities.  The statement for (;x<10;) printf("Hi\n"); is
  889. *      exactly equivalent to while (x<10) printf("Hi\n");, (Well at
  890. *      least functionally it is, I don't know how the computer sees
  891. *      it).  All of the parts of the for loop are completely optional
  892. *      so you can pick and choose what you need and what you don't.
  893. *      for example the statement for (;;) {  }  throws the program
  894. *      into an infinite loop, which may only be broken out of
  895. *      using a break statement.  Also it is worthwhile to mention
  896. *      that each part of the for loop may contain multiple
  897. *      declarations, test conditions, and statements. for instance
  898. *      for (x = 0, y = 10; x<=10 && y>=0; x++, y--)
  899. *         printf("%3d, %3d\n", x, y);
  900. *      tells the program to set x equal to 0 and y to 10, to keep
  901. *      going until either x is greater than 10 or y becomes less than
  902. *      zero and to increment x and decrement y after printf() prints
  903. *      it's little message.
  904. *
  905. *   INPUTS
  906. *      <variable assignments> - A list of variables to assign a value
  907. *                               to, or in rare cases any other
  908. *                               statement you would wish only to
  909. *                               execute at the beginning of the for
  910. *                               loop.  Frankly statements should
  911. *                               probably just come before the for
  912. *                               loop as a matter of good form.  Each
  913. *                               assignment should be separated by a
  914. *                               comma.
  915. *      <test conditions> - Truly only one test condition can be put
  916. *                          here, however, in practice you may just
  917. *                          separate each test condition by a && or
  918. *                          || or any other C test operator depending
  919. *                          on how you think the thing should work,
  920. *                          and thus have multiple test conditions.
  921. *      <statements> - I called this one statements for lack of a
  922. *                     better word.  This space is typically used for
  923. *                     incrementing and/or decrementing the values
  924. *                     initialized in the first part of the for loop,
  925. *                     however, any statements may go here.  Again
  926. *                     I think as a matter of good form you should
  927. *                     try to stick to incrementing and decrementing,
  928. *                     and if you really have to have some statements
  929. *                     execute, then just stick them at the end of the
  930. *                     <statement sequence>.
  931. *      <statement sequence> - The single statement or block of
  932. *                             statements which is/are to be executed.
  933. *
  934. *   RESULT
  935. *      none.
  936. *
  937. *   EXAMPLE
  938. *      for (x = 0, y = 0; x < 10; x++, y+=2)
  939. *      {
  940. *         printf("%3d, %3d\n", x, y);
  941. *      }
  942. *
  943. *   NOTES
  944. *      When I first learned C, coming from BASIC, I thought that C
  945. *      for loops were needlessly ambiguous, and generally retarded,
  946. *      however later, after a couple books, much tinkering, and a lot
  947. *      of, "Ohhhhh, that's why;)", I learned that the small sacrifice
  948. *      in straight forwardness yielded 10 times to the functionality
  949. *      and applicability of the construct.  I personally regard the C
  950. *      for loop as one of the most useful features of the language,
  951. *      and it's certainly something that sets it apart from most other
  952. *      languages which lock you into a certain way of doing it.
  953. *      The way I got through the fact that the C for loop isn't very
  954. *      obvious to the beginning programmer, is to invent a dialogue
  955. *      for translating what the for loop is doing into English.  When
  956. *      you see the statement
  957. *      for (x = 0; x < 10; x++) {printf("hi\n");
  958. *      you can translate it as , set x equal to 0, while x is less
  959. *      than 10 execute printf("hi\n") and increment x, then repeat.
  960. *      It's useful to look at the for loop as a while loop with added
  961. *      capabilities.  Also remember that any and all parts of a for
  962. *      loop are completely optional, and that each part may contain
  963. *      multiple statements, test conditions etc.
  964. *
  965. *   BUGS
  966. *      Bugs you say, nope, none here.
  967. *
  968. *   SEE ALSO
  969. *      do, while, switch, break, continue, default, if, else.
  970. *
  971. *********************************************************************/
  972.  
  973. /****** /goto ********************************************************
  974. *
  975. *   NAME
  976. *      goto - Jumps to another part of the program.  NEVER USE!!!!
  977. *             If your code ever leeks out and other programmers get
  978. *             wind, you're reputation will never recover, companies
  979. *             won't hire you, you'll be an outcast, shunned by all
  980. *             but the most loathsome of BASIC programmers.
  981. *
  982. *   SYNOPSIS
  983. *      goto <label>
  984. *
  985. *
  986. *      <label>:
  987. *
  988. *   FUNCTION
  989. *      Goto has no function, it has no reason to exist, but to satisfy
  990. *      those unimaginative BASIC programmers who dare set their
  991. *      obviously unadaptable feet into C water just to have them
  992. *      ripped off by some shark in the guise of a nerdy keyboard
  993. *      jockey.  No, but seriously, goto is regarded by all as bad
  994. *      programming technique, and should be avoided at all cost on
  995. *      pain of unintelligible source code, both to you and anyone else
  996. *      who might have business with it later.  There is only one
  997. *      conceivable instance that I'm aware of where goto might be an
  998. *      actual benefit to source code readability.  Say you have
  999. *      yourself nested in several layers of loops and some condition
  1000. *      happens, (maybe an error or even some debug code), and you have
  1001. *      to exit out of all of the loops.  It is inconvenient to use
  1002. *      breaks, because you have to put one into every loop until your
  1003. *      safely back into wherever the original calling code was.
  1004. *      Frankly, it's probably a better idea to rethink the way your
  1005. *      doing it and try to come up with a way that doesn't involve
  1006. *      goto unless it's just temporary debug code which will be taken
  1007. *      out after the bug has been solved.
  1008. *
  1009. *   INPUTS
  1010. *      <label> - Is the only argument goto takes.  You must put a
  1011. *                label somewhere in the code of the current function
  1012. *                you are in.  goto will not find a label if it is
  1013. *                located in another function.  the label is followed
  1014. *                by a colon when marking the location, but not when
  1015. *                used with goto.  If I didn't explain that well see
  1016. *                the example and it should become clear.
  1017. *
  1018. *   RESULT
  1019. *      none.
  1020. *
  1021. *   EXAMPLE
  1022. *      label:
  1023. *         printf("Hello World ;-)\n");
  1024. *      goto label;
  1025. *
  1026. *   NOTES
  1027. *      A lot of C and C++ programmers truly wonder why goto was
  1028. *      included in the language when it already had such a rich set of
  1029. *      control structures?  I personally believe it's because C was
  1030. *      originally cooked up in the 60s or 70s, or something, when
  1031. *      basic programming was all the rage.  When people finally
  1032. *      realized that goto wasn't all it was cracked up to be, it was
  1033. *      too late to take it out of the language for backward
  1034. *      compatibility's sake.  That being said I'll make a note here
  1035. *      that should in no way convince you that using goto is OK.  Goto
  1036. *      is generally faster than the built in control structures
  1037. *      because it's tailored to the specific task at hand and doesn't
  1038. *      generate redundant code.  Also I think each time you use a C
  1039. *      control stucture there's a certain amount of overhead involved,
  1040. *      but don't quote me on that.  If you ever look at assembly,
  1041. *      you'll see the equivilant of gotos all over the place.  Goto
  1042. *      is alot closer to how the machine thinks than the other control
  1043. *      structures.  However, truly the amount of time lost by using C
  1044. *      constructs is truly minimal and is barely worth mentioning.
  1045. *      Personally, and I know someone is going to blast me for this,
  1046. *      I'm glad it was included in the language, even though I and
  1047. *      nobody else ever uses it.  I always like having the choice to
  1048. *      do things the way I like, which is truly what C programming is
  1049. *      all about anyway.  The language doesn't dictate matters of
  1050. *      style, that job is left to the programmer where it belongs.
  1051. *      P.S. Unions also fall into the category of "why", but again,
  1052. *      I think that just because a feature doesn't fit all situations,
  1053. *      or even most situations, it is at least nice to know it's there
  1054. *      for that one out of a million chance you might actually use it.
  1055. *
  1056. *   BUGS
  1057. *      You shouldn't use this keyword enough to know if there are any
  1058. *      bugs.  In fact, if you're still reading this, there's something
  1059. *      wrong.  Here, directly below are a list of things you can use
  1060. *      instead.
  1061. *
  1062. *   SEE ALSO
  1063. *      for, while, do, switch, break, continue,
  1064. *      THE WHOLE CONCEPT OF USING FUNCTIONS TO ENCAPSULATE CODE & DATA
  1065. *
  1066. *
  1067. *********************************************************************/
  1068.  
  1069. /****** /if **********************************************************
  1070. *
  1071. *   NAME
  1072. *      if - Used to form (if-then) constructs.  Is the basic way to
  1073. *           make decisions in C.
  1074. *
  1075. *   SYNOPSIS
  1076. *      if (<conditional statement>)
  1077. *      {
  1078. *         <statement sequence>;
  1079. *      }
  1080. *      else if (<conditional statement>)
  1081. *      {
  1082. *         <statement sequence>;
  1083. *      }
  1084. *      else
  1085. *      {
  1086. *         <statement sequence>;
  1087. *      }
  1088. *
  1089. *   FUNCTION
  1090. *      If is used to form (if-then) constructs.  It is the basic way
  1091. *      to make decisions in C.  Basically, anytime you have to choose
  1092. *      between two courses of action based on some data or user input
  1093. *      you use an if.  If tests for truth, (if such and such is true
  1094. *      then do something or other else do this other thing).  Anything
  1095. *      that is unequal to 0 is true, zero is false.  2+2 is true,
  1096. *      2-2 is false...  If this makes little sense, don't worry, I'm
  1097. *      not explaining it well anyway.  if you put a statement in your
  1098. *      code like printf("%d\n", 2==2), then the output would most
  1099. *      likely be 1 or -1, but could honestly be anything other than 0.
  1100. *      Likewise printf("%d\n", 2==4), would output 0.  Usually when
  1101. *      testing for truth you use the symbols > < >= <= != == && ||.
  1102. *      >  greater than
  1103. *      <  less than
  1104. *      >= greater than or equal to
  1105. *      <= less than or equal to
  1106. *      != not equal to
  1107. *      == equal to
  1108. *      && and
  1109. *      || or
  1110. *      These are all logical operators as opposed to bitwise
  1111. *      operators which are used to manipulate binary values.
  1112. *
  1113. *   INPUTS
  1114. *      <conditional statement> - A statement which evaluates to either
  1115. *                                true or false.  False is equal to 0
  1116. *                                and true is anything else, however
  1117. *                                it is common practice to have -1 or 1
  1118. *                                represent true.
  1119. *      <statement sequence> - The single statement or block of
  1120. *                             statements which is/are to be executed.
  1121. *
  1122. *   RESULT
  1123. *      none.
  1124. *
  1125. *   EXAMPLE
  1126. *      if (x==3) printf("x is equal to 3\n");
  1127. *      else
  1128. *      {
  1129. *         printf("OK, you were wrong.\n");
  1130. *         printf("x is not equal to 3.\n");
  1131. *      }
  1132. *
  1133. *   NOTES
  1134. *      Get used to if.  You'll be using it a lot.
  1135. *
  1136. *   BUGS
  1137. *      Aside from being iffy, "Ok, Ok, bad joke", none.
  1138. *
  1139. *   SEE ALSO
  1140. *      switch.
  1141. *
  1142. *********************************************************************/
  1143.  
  1144. /****** /int *********************************************************
  1145. *
  1146. *   NAME
  1147. *      int - Declares variables of type int, (quite possibly the most
  1148. *            commonly used data type in C programming.)
  1149. *
  1150. *   SYNOPSIS
  1151. *      int <variable list>;
  1152. *
  1153. *   FUNCTION
  1154. *      int declares variables of type int.  Assuming that integers
  1155. *      are a 16 bit data type, (on some computers they're 32 bits
  1156. *      by default, but could be 64 or anything else depending on
  1157. *      the hardware), an integer is any whole number which falls
  1158. *      between the ranges of -32768 and 32767.  An integer must be
  1159. *      at least that large.  A long integer must likewise be at
  1160. *      least a 32 bit number meaning anything between -2147483648 and
  1161. *      2147483647.
  1162. *
  1163. *   INPUTS
  1164. *      <variable list> - Is a list of variables to be declared as
  1165. *                        type int separated by commas.
  1166. *
  1167. *   RESULT
  1168. *      none.
  1169. *
  1170. *   EXAMPLE
  1171. *      int x, y = 2, z[5] = {1, 2, 3, 4, 5};
  1172. *
  1173. *   NOTES
  1174. *      Integers are just about the fastest datatype in C.
  1175. *      Calculations done with ints are lightning fast, plus
  1176. *      by using the register keyword you can ask the C compiler
  1177. *      to store them directly in the CPU's memory so access is
  1178. *      even faster.  The down side of course is you can't do
  1179. *      fractions in the traditional sense.  5/2 yields 2.  The
  1180. *      remainder is simply chopped off.  To retain the whole
  1181. *      answer with the remainder use the div function found in
  1182. *      the stdlib.h.  There are ways you can get ints and long ints
  1183. *      to do just about any job you want done, it just takes a little
  1184. *      fore-thought. 
  1185. *
  1186. *   BUGS
  1187. *      Only works on whole numbers and can't hold very large numbers.
  1188. *
  1189. *   SEE ALSO
  1190. *      void, char, float, double.
  1191. *
  1192. *      long, short, signed, unsigned,
  1193. *      const, volatile,
  1194. *      extern, static, register, auto,
  1195. *      struct, union, typedef, enum.
  1196. *
  1197. *********************************************************************/
  1198.  
  1199. /****** /long ********************************************************
  1200. *
  1201. *   NAME
  1202. *      long - Is an access modifier, which can be used to preface 
  1203. *             either int or double to change their meaning, usually
  1204. *             to increase their size.
  1205. *
  1206. *   SYNOPSIS
  1207. *      long <data type> <variable list>;
  1208. *
  1209. *   FUNCTION
  1210. *      Long is an access modifier, which can be used to preface either
  1211. *      int or double to change their meaning, usually to increase
  1212. *      their size.  long can be used by itself and it is understood
  1213. *      that you mean long int.  A normal integer is usually 16 bits
  1214. *      long, but a long integer is typically 32 bits long meaning
  1215. *      instead of being able to only hold a max 32,767 a long can
  1216. *      hold 2,147,483,647.  Similarly when used in reference to
  1217. *      double it specifies that it should take up, (I think), 80
  1218. *      bits instead of the normal 64.  This translates from something
  1219. *      like 1.7 * 10^308 into 3.4 * 10^4932.  Don't quote me on
  1220. *      that last one, I don't think long double's are very standard,
  1221. *      and seriously, if you ever need a number that big, or that
  1222. *      accurate, it probably means your a much better programmer than
  1223. *      I, and you have no business reading this anyway unless of
  1224. *      course it's for a good laugh.
  1225. *
  1226. *   INPUTS
  1227. *      <data type> - In this case can only be int or double.
  1228. *
  1229. *      <variable list> - A list of variables to be declared as
  1230. *                        long, or long double.
  1231. *
  1232. *   RESULT
  1233. *      none.
  1234. *
  1235. *   EXAMPLE
  1236. *      long x, y = 2, z = 1000000;
  1237. *                    // same as long int x, y = 2, z = 1000000;
  1238. *
  1239. *   NOTES
  1240. *      Long is one of those funny things that got really screwed
  1241. *      up when the ANSI folks decided to mess around with
  1242. *      it's meaning.  Originally in the old Kernigan & Ritchie
  1243. *      standard of C, long made a whole lot more sense.  You
  1244. *      had the standard data types like char int and float.
  1245. *      ints were either short or long, likewise floats too
  1246. *      were either short or long.  If you didn't specify the
  1247. *      keyword long then it was assumed to be short.  Ints were
  1248. *      16 bits short 32 long, floats were 32 short and 64 long.
  1249. *      In fact the keyword double and long float are synonymous.
  1250. *      and long doubles didn't exist.  To me, that makes sense,
  1251. *      but when the ANSI people came to standardize C compilers
  1252. *      everywhere, (and they did a good job, I just don't like
  1253. *      the way they did this), they not only said that we're now
  1254. *      going to call long floats double and make a new long
  1255. *      double type, but they made it illegal to make a long
  1256. *      float.  If you try it, I'll lay you 10 to 1 odds your
  1257. *      compiler will choke.  Anyway, so now years after the
  1258. *      ANSI standard, long has a very obscure meaning now,
  1259. *      at least in reference to what it meant originally.
  1260. *
  1261. *   BUGS
  1262. *      Only works with int and double.  Otherwise none.
  1263. *
  1264. *   SEE ALSO
  1265. *      void, int, char, float, double.
  1266. *
  1267. *      short, signed, unsigned,
  1268. *      const, volatile,
  1269. *      extern, static, register, auto,
  1270. *      struct, union, typedef, enum.
  1271. *
  1272. *********************************************************************/
  1273.  
  1274. /****** /register ****************************************************
  1275. *
  1276. *   NAME
  1277. *      register - Is an access modifier which is used to specify
  1278. *                 to the compiler that the following variable
  1279. *                 declarations are such that speed is crucial
  1280. *                 and that the compiler should perform added
  1281. *                 optimizations on these variables.
  1282. *
  1283. *   SYNOPSIS
  1284. *      register <data type> <variable list>;
  1285. *
  1286. *   FUNCTION
  1287. *      Register is an access modifier which is used to specify to the
  1288. *      compiler that the following variable declarations are such that
  1289. *      speed is crucial and that the compiler should perform added
  1290. *      optimizations on these variables.  Really this keyword should
  1291. *      only be used on ints, which you would like to be stored in
  1292. *      the CPU's registers so they take up less access time, (hence
  1293. *      the name register).  Only ints can be stored in the CPU's
  1294. *      registers, and it should be understood that this is only
  1295. *      a request and not a command, the compiler may or may not
  1296. *      store the variables in question in the CPU's registers,  it
  1297. *      may or may not perform added optimizations on the variables
  1298. *      that can't go into the registers.
  1299. *
  1300. *   INPUTS
  1301. *      <data type> - Any C data type, (i.e. char, int, float, double)
  1302. *      <variable list> - A list of variable being declared separated
  1303. *                        by commas.
  1304. *
  1305. *   RESULT
  1306. *      none.
  1307. *
  1308. *   EXAMPLE
  1309. *      register int x, y = 0;
  1310. *
  1311. *   NOTES
  1312. *      It's pretty much just a simple way to make you feel like
  1313. *      you've optimized your code, when in fact the speed difference
  1314. *      is minimal.  Really the best way to optimize a program is well
  1315. *      thought out algorithms that do their job with as little pull
  1316. *      on the CPU as possible.
  1317. *
  1318. *   BUGS
  1319. *      It's only a request, it may or may not have any effect.
  1320. *
  1321. *   SEE ALSO
  1322. *      void, char, int, float, double.
  1323. *
  1324. *      long, short, signed, unsigned,
  1325. *      const, volatile,
  1326. *      extern, static, auto,
  1327. *      struct, union, typedef, enum.
  1328. *
  1329. *********************************************************************/
  1330.  
  1331. /****** /return ******************************************************
  1332. *
  1333. *   NAME
  1334. *      return - Exits a function immediately and a return value may
  1335. *               be specified.
  1336. *
  1337. *   SYNOPSIS
  1338. *      <data type> <function name>(<argument list>)
  1339. *      {
  1340. *         <statement sequence>;
  1341. *         return <return value>;
  1342. *      }
  1343. *
  1344. *   FUNCTION
  1345. *      Return exits a function immediately and a return value may
  1346. *      be specified.  Unless a function declares a void return type
  1347. *      it must have at least one return statement that terminates
  1348. *      the function and returns a value of the appropriate type.
  1349. *      A function may have multiple return statements.
  1350. *
  1351. *   INPUTS
  1352. *      <data type> - May be any of C's built in data types or it
  1353. *                    may be a user defined (complex) data type, such
  1354. *                    as a struct.
  1355. *      <function name> - Any valid identifier which serves as the
  1356. *                        name of the function.
  1357. *      <argument list> - An argument list consists of variable
  1358. *                        declarations separated by commas.  See
  1359. *                        the example for clarification on this.
  1360. *      <statement sequence> - The single statement or block of
  1361. *                             statements which is/are to be executed.
  1362. *      <return value> - The data to be passed back to the routine
  1363. *                       that originally called the function.
  1364. *
  1365. *   RESULT
  1366. *      What should I write for this, it is the result.  This is the
  1367. *      mechanism by which a result is produced.
  1368. *
  1369. *   EXAMPLE
  1370. *      int main(int argc, char *argv)
  1371. *      {
  1372. *
  1373. *         printf("Hello dare\n");
  1374. *         return 0;
  1375. *      }
  1376. *
  1377. *   NOTES
  1378. *      none.
  1379. *   BUGS
  1380. *      none.
  1381. *
  1382. *   SEE ALSO
  1383. *
  1384. *********************************************************************/
  1385.  
  1386. /****** /short *******************************************************
  1387. *
  1388. *   NAME
  1389. *      short - Is an access modifier, which can be used to preface 
  1390. *              int to change it's meaning.
  1391. *
  1392. *   SYNOPSIS
  1393. *      short int <variable list>;
  1394. *
  1395. *   FUNCTION
  1396. *      short is an access modifier, which can be used to preface int
  1397. *      to change it's meaning.  Actually, in practice, a short int
  1398. *      is the same as saying int, and likewise short can be specified
  1399. *      by itself where the definition short x; is the same as saying
  1400. *      int x;  technically, ints can be 16 or 32 bits, (or really any
  1401. *      number of bits depending on the machine), and short is any
  1402. *      number of bits less than or equal to the default int.
  1403. *
  1404. *   INPUTS
  1405. *      <variable list> - A list of variables to be declared separated
  1406. *                        by commas.
  1407. *
  1408. *   RESULT
  1409. *      none.
  1410. *
  1411. *   EXAMPLE
  1412. *      short int x, y = 0;
  1413. *         // same as short x, y = 0;
  1414. *
  1415. *   NOTES
  1416. *      Short and long are two of a kind so you should take a look
  1417. *      at what long is all about as well.  Short can only be applied
  1418. *      to integers, while long can be applied to ints and doubles.
  1419. *      Again I think the ANSI standard kind of changed the meaning of
  1420. *      short, which is all right, and since I don't know how it was
  1421. *      originally used, and don't have any pre-ANSI compilers to test
  1422. *      it out on, I'm just going to leave a big hairy blank on the
  1423. *      history.  In general short and long should only be used on
  1424. *      ints, and on a more personal note, I've never used the short
  1425. *      keyword once to my recollection.  Usually it's assumed that
  1426. *      ints are shorts, and if your computer or compiler is more
  1427. *      comfortable with 32 bit numbers than 16, why limit the size
  1428. *      when there's no need.  Bottom line, you'll probably use long
  1429. *      all the time, but probably forget short even exists.
  1430. *
  1431. *   BUGS
  1432. *      none to my knowledge.
  1433. *
  1434. *   SEE ALSO
  1435. *      long,
  1436. *
  1437. *      void, int, char, float, double.
  1438. *
  1439. *      signed, unsigned,
  1440. *      const, volatile,
  1441. *      extern, static, register, auto,
  1442. *      struct, union, typedef, enum.
  1443. *
  1444. *********************************************************************/
  1445.  
  1446. /****** /signed ******************************************************
  1447. *
  1448. *   NAME
  1449. *      signed - Is an access modifier which may be used on either
  1450. *               character or integer data types.
  1451. *
  1452. *   SYNOPSIS
  1453. *      signed <data type> <variable list>;
  1454. *
  1455. *   FUNCTION
  1456. *      Signed is an access modifier which may be used on either
  1457. *      character or integer data types.  Signed is used mainly
  1458. *      to specify that a char can either be negative or positive.
  1459. *      Doing this causes the maximum number a char can hold to be
  1460. *      cut in half.  Really all variable types, including char, are
  1461. *      signed by default so I'm not sure that there is ever an
  1462. *      instance where you would want to use this modifier.
  1463. *
  1464. *   INPUTS
  1465. *      <data type> - In this case either char or int.
  1466. *      <variable list> - A list of variables to be declared separated
  1467. *                        by commas.
  1468. *
  1469. *   RESULT
  1470. *      none.
  1471. *
  1472. *   EXAMPLE
  1473. *      signed char x, y = -100;
  1474. *      printf("%d\n", y);
  1475. *
  1476. *   NOTES
  1477. *      Notice that in the example above when I printed y with
  1478. *      printf I used a %d instead of %c which is normally used
  1479. *      for characters.  The reason is, I'm using the type char
  1480. *      here to store numbers and not characters in the normal sense.
  1481. *
  1482. *   BUGS
  1483. *      none.
  1484. *
  1485. *   SEE ALSO
  1486. *      unsigned,
  1487. *
  1488. *      void, int, char, float, double.
  1489. *
  1490. *      long, short, const, volatile,
  1491. *      extern, static, register, auto,
  1492. *      struct, union, typedef, enum.
  1493. *
  1494. *********************************************************************/
  1495.  
  1496. /****** /sizeof ******************************************************
  1497. *
  1498. *   NAME
  1499. *     sizeof - Is used to calculate the size of variables and other
  1500. *              objects.
  1501. *
  1502. *   SYNOPSIS
  1503. *     size_t sizeof(<variable type>)<expression>;
  1504. *     or
  1505. *     size_t sizeof <variable> <expression>;
  1506. *
  1507. *   FUNCTION
  1508. *      Sizeof is used to calculate the size of variables and other
  1509. *      objects.  Sizeof is useful in determining the size of a
  1510. *      variable or other object, but it's most useful application is
  1511. *      in calculating the size for an object that is being dynamically
  1512. *      allocated.  Basically malloc() and sizeof go together like
  1513. *      peanut butter and jelly.
  1514. *
  1515. *   INPUTS
  1516. *      <variable type> - Can be any of C's built in type's or a user
  1517. *                        defined type like a struct or something.
  1518. *      <variable> - Or you can use the variable itself.  sizeof will
  1519. *                   return how much memory it's taking up.
  1520. *      <expression> - Any expression which you might want to use to
  1521. *                     modify the number that sizeof returns.
  1522. *
  1523. *   RESULT
  1524. *      size_t - Is the size of the object passed to sizeof in bytes.
  1525. *               size_t is defined in stddef.h.  Technically speaking,
  1526. *               sizeof figures an objects size as a multiple of the
  1527. *               char type, (which is almost always a byte).  If your
  1528. *               computer stores characters in something larger than
  1529. *               an 8 bit byte, then you might have to rethink your
  1530. *               implementation.  In practice though, I've never heard
  1531. *               of this happening.
  1532. *
  1533. *   EXAMPLE
  1534. *      #include <stdio.h>
  1535. *      #include <stdlib.h>
  1536. *
  1537. *      struct test
  1538. *      {
  1539. *         int i;
  1540. *         char c;
  1541. *      } teststruct; typedef struct test test;
  1542. *      
  1543. *      int main(void)
  1544. *      {
  1545. *         int x, *ptr;
  1546. *         ptr = (int *)malloc(sizeof(int)*5);
  1547. *         for (x = 0; x < 5; x++)
  1548. *         {
  1549. *             *(ptr+x) = x;
  1550. *             printf("%d\n", *(ptr+x));
  1551. *         }
  1552. *         printf("Won't work, sizeof ptr isn't %d\n", sizeof(ptr));
  1553. *         printf("size of x is %d\n", sizeof(x));
  1554. *         printf("size of teststruct is %d\n", sizeof(teststruct));
  1555. *         printf("testtruct should be sizeof(int)+sizeof(char).\n");
  1556. *         printf("just to test, sizeof(int)+sizeof(char)==%d\n",
  1557. *            sizeof(int)+sizeof(char));
  1558. *         return 0;
  1559. *      }
  1560. *
  1561. *   NOTES
  1562. *      Sizeof is a unary operator.  I almost always use it as though
  1563. *      it were a function, but it is an operator none the less.
  1564. *      malloc and it's related functions calloc realloc and free
  1565. *      which are used to allocate memory from the operating system
  1566. *      are where sizeof gets used most often.
  1567. *      Also the type size_t is defined in stddef.h.
  1568. *
  1569. *   BUGS
  1570. *      none.
  1571. *
  1572. *   SEE ALSO
  1573. *      size_t, malloc, calloc, realloc, free. 
  1574. *
  1575. *********************************************************************/
  1576.  
  1577. /****** /static ******************************************************
  1578. *
  1579. *   NAME
  1580. *      static - Is used to specify that a variable is to remain in
  1581. *               memory even when the function or block to which
  1582. *               it is assigned goes out of scope.
  1583. *
  1584. *   SYNOPSIS
  1585. *      static <data type> <variable list>
  1586. *
  1587. *   FUNCTION
  1588. *      Static is used to specify that a variable is to remain in
  1589. *      memory even when the function or block to which it is assigned
  1590. *      goes out of scope.  Simply stated, normally when you exit a
  1591. *      function, all local variables in that function are destroyed
  1592. *      so the memory can be used elsewhere, (i.e., when you go back
  1593. *      into that function later, the variables are not the same as
  1594. *      when you left the function.)  The static keyword specifies
  1595. *      that you don't want the memory to be dumped, so when you
  1596. *      come back into the function, everything is just as you left
  1597. *      it.  There are two practical uses for static variables that
  1598. *      come blaringly to mind.  One is when you need to keep track
  1599. *      of some bit of info between function calls, (like maybe
  1600. *      how many times you've called the function or something).  The
  1601. *      other is when you want to return a pointer to info generated
  1602. *      by the function, but don't want to declare a global variable
  1603. *      and call by value isn't economical.
  1604. *
  1605. *      There is a another and somewhat confusing use of the keyword
  1606. *      static, which is to specify that a global identifier, (which
  1607. *      can be any identifier including a variable or function), is
  1608. *      to have internal linkage.  What this means is basically that
  1609. *      say you have two source code files and both of them contain
  1610. *      either functions and/or variables with the same names.  If you
  1611. *      try to compile them together, you'll get an error from the
  1612. *      compiler.  If you declare the vars and or functions in question
  1613. *      with the static keyword it tells the compiler that the source
  1614. *      code is useing the variable within itself and not the one that
  1615. *      was defined in the other source code file.  At first this looks
  1616. *      like a useless feature that no-one in their right mind would
  1617. *      use, but it does have one VERY important use.  The problem with
  1618. *      global variables is that they can very quickly polute your code
  1619. *      which is why you're encouraged to use static variables within
  1620. *      a function.  Sometimes however, you have to use a global var
  1621. *      to get the job done, and there's no way around it.  Well if
  1622. *      you're working on a large project made up of multiple files
  1623. *      you can use the static keyword when you define your global
  1624. *      variable, and it will in effect shield all the other source
  1625. *      file segments from your global variable.  They won't be
  1626. *      aware that it even exists.  I suggest you play with this a
  1627. *      little, as it's an extremely useful tool for allowing you to
  1628. *      "cheat" the system, and still have super clean code.
  1629. *
  1630. *   INPUTS
  1631. *      <data type> - Any of C's built in data types, or a user defined
  1632. *                    (complex) data type of your own.
  1633. *      <variable list> - A list of variables being declared separated
  1634. *                        by commas.
  1635. *
  1636. *   RESULT
  1637. *      none.
  1638. *
  1639. *   EXAMPLE
  1640. *      #include <stdio.h>
  1641. *
  1642. *      int *test(int a, int b);
  1643. *
  1644. *      int main(void)
  1645. *      {
  1646. *         int x, *mainptr;
  1647. *
  1648. *         mainptr = test(0, 10);
  1649. *         for (x = 0; x < 10; x++) printf("%d\n", *(ptr+x));
  1650. *         printf("\n\n\n");
  1651. *         mainptr = test(5, 15);
  1652. *         for (x = 0; x < 15; x++) printf("%d\n", *(ptr+x));
  1653. *
  1654. *         return 0;
  1655. *      }
  1656. *
  1657. *      int *test(int a, int b)
  1658. *      {
  1659. *         int x;
  1660. *         static int *ptr = NULL;
  1661. *
  1662. *         if (ptr==NULL) ptr = (int *)malloc(sizeof(int)*b);
  1663. *         else ptr = (int *)realloc(ptr, sizeof(int)*b); 
  1664. *         for (x = a; x < b; x++) *(ptr+x) = x;
  1665. *         return ptr;
  1666. *      }
  1667. *
  1668. *   NOTES
  1669. *      Static shouldn't be used when it's not needed, but it is an
  1670. *      invaluable tool for maintaining the structure of a program
  1671. *      when trying to do some things.  Mainly static's main purpose
  1672. *      for existing is to limit the need for global variables.
  1673. *      Indeed even when the use of global variables is necessary,
  1674. *      the static keyword can be used to limit the impact they have
  1675. *      on the overall program.
  1676. *
  1677. *   BUGS
  1678. *      none.  Sorry if I didn't explain this keyword well.  It's
  1679. *      a little hard for me to word.  When all else fails,
  1680. *      experiment, a little old fashioned hacking never hurt
  1681. *      anyone.
  1682. *
  1683. *   SEE ALSO
  1684. *      auto, extern, register, const, volatile,
  1685. *
  1686. *      void, char, int, float, double.
  1687. *      long, short, signed, unsigned,
  1688. *      struct, union, typedef, enum.
  1689. *
  1690. *********************************************************************/
  1691.  
  1692. /****** /struct ******************************************************
  1693. *
  1694. *   NAME
  1695. *      struct - Is used to create user defined (complex) variable
  1696. *               types on top of C's built in types.
  1697. *
  1698. *   SYNOPSIS
  1699. *      struct <type name>
  1700. *      {
  1701. *         <variable declarations>;
  1702. *      } <global variable list>;
  1703. *
  1704. *   FUNCTION
  1705. *      Struct is used to create user defined (complex) variable
  1706. *      types on top of C's built in types.  Basically struct allows
  1707. *      you to structure a bunch of variables into a logical grouping.
  1708. *      If your familiar with the concept and terminology of databases
  1709. *      a struct is like making a field, which will later contain
  1710. *      a whole bunch of data pertaining to a single subject.
  1711. *      If the idea is unclear, try looking at the example for
  1712. *      clarification.
  1713. *
  1714. *   INPUTS
  1715. *      <type name> - Is the name of the new type you are creating.
  1716. *                    Think of this as roughly corresponding to int,
  1717. *                    char, or float or the like with the exception
  1718. *                    that this is your own custom variable type.
  1719. *      <variable declarations> - Several lists of variable
  1720. *                                declarations which may be made up of
  1721. *                                any of C's built in types, or of
  1722. *                                other user defined (complex) types
  1723. *                                defined elsewhere.
  1724. *      <global variable list> - A list of variables of this newly
  1725. *                               defined type separated by commas.  Any
  1726. *                               variables declared here are considered
  1727. *                               global.  You may declare global
  1728. *                               variables of this type elsewhere but
  1729. *                               it is considered proper to do it here.
  1730. *
  1731. *   RESULT
  1732. *      none.
  1733. *
  1734. *   EXAMPLE
  1735. *      #include <stdio.h>
  1736. *      #include <string.h>
  1737. *
  1738. *      struct phonepage
  1739. *      {
  1740. *         char name[257];
  1741. *         int areacode, localcode, fourdigitcode;
  1742. *         char address[257];
  1743. *      } phonebook[10];
  1744. *
  1745. *      // the following line is just so you can type phonepage
  1746. *      // instead of typing struct phonepage to declare a variable
  1747. *      // of that type.  THIS IS NOT A NECESSARY STATEMENT.
  1748. *      // It is intended to make the meaning of the statements in main
  1749. *      // stand out more clearly.
  1750. *      typedef struct phonepage phonepage;
  1751. *
  1752. *      int main(void)
  1753. *      {
  1754. *         phonepage myfriend;
  1755. *
  1756. *         strcpy(myfriend.name, "Harry");
  1757. *         myfriend.areacode = 900;            
  1758. *         myfriend.localcode = 555;
  1759. *         myfriend.fourdigitcode = 1234;
  1760. *         strcpy(myfriend.address,
  1761. *            "Beverly Hill 90210, <Yeah right ;-)>");
  1762. *
  1763. *         phonebook[0] = myfriend;
  1764. *
  1765. *         printf("My friend's name is %s\n", phonebook[0].name);
  1766. *         printf("My friend's phone number is (%d) %d-%d\n",
  1767. *            phonebook[0].areacode, phonebook[0].localcode,
  1768. *            phonebook[0].fourdigitcode);
  1769. *         printf("my friend's address is %s\n", phonebook[0].address);
  1770. *
  1771. *         return 0;
  1772. *      }
  1773. *
  1774. *   NOTES
  1775. *      When I first started learning C, the syntax of how to construct
  1776. *      a struct really baffled me, mostly because in many of
  1777. *      the books I was reading each programmer had a different way
  1778. *      of doing it.  Specifically the difference between the name at
  1779. *      the beginning and the list of names that follows the definition
  1780. *      threw me for a loop.  It was never impressed on me by the
  1781. *      different authors, that the name at the top is a new variable
  1782. *      type, and the list of names at the end are simply variables of
  1783. *      that type.  Structs are really the first glimmer of the object
  1784. *      oriented way of looking at a problem.  C is not an object
  1785. *      oriented language, but structs promote the grouping of data
  1786. *      into logical/conceptual objects.  C++ takes the next step and
  1787. *      lets you put code into your own variables as well as data.
  1788. *      There's more to object oriented programming then just that,
  1789. *      but I'm just trying to impress that if you've no idea what
  1790. *      object oriented programming is, Structs definitely fall into
  1791. *      the spirit of object oriented programming.
  1792. *      P.S. a structure can also be used to create a bit field.
  1793. *      A bit field is useful when you want to pack as much info
  1794. *      into a given piece of memory as is humanly possible.
  1795. *      This is an advanced technique which I'm too lazy to go into
  1796. *      in depth here.  If you think you might need one, or are just
  1797. *      interested, or need the syntax, pick up any book on C
  1798. *      programming and look in the index for bit fields.
  1799. *      A bit field looks something like this,
  1800. *      struct test
  1801. *      {
  1802. *         int bool1 : 1;
  1803. *         int bool2 : 1;
  1804. *         int byte1 : 8;
  1805. *         int byte2 : 8;
  1806. *      } ;
  1807. *
  1808. *   BUGS
  1809. *      none.
  1810. *
  1811. *   SEE ALSO
  1812. *      typedef, union, enum,
  1813. *
  1814. *      void, char, int, float, double.
  1815. *      long, short, signed, unsigned,
  1816. *      const, volatile,
  1817. *      extern, static, register, auto.
  1818. *
  1819. *********************************************************************/
  1820.  
  1821. /****** /switch ******************************************************
  1822. *
  1823. *   NAME
  1824. *      switch - A statement used to choose between alternate courses
  1825. *               of action based on an integer or enumeration value.
  1826. *
  1827. *   SYNOPSIS
  1828. *      switch (<variable>)
  1829. *      {
  1830. *         case <const value>:
  1831. *            <statement sequence>;
  1832. *            break; // if this is omitted, 2nd case will execute too.
  1833. *         case <const value>:
  1834. *            <statement sequence>;
  1835. *            break;
  1836. *         default:
  1837. *            <statement sequence>;
  1838. *      }
  1839. *
  1840. *   FUNCTION
  1841. *      Switch is a statement used to choose between alternate courses
  1842. *      of action based on an integer or enumeration value.  Switch
  1843. *      is similar in purpose to an If-Then, but is more restrictive.
  1844. *      Essentially all a switch can test for is equality.  When a
  1845. *      single variable must be tested multiple times for equality
  1846. *      and a simple inequality won't suffice, a switch statement
  1847. *      can add more clarity to the code then an if-else if ladder.
  1848. *
  1849. *   INPUTS
  1850. *      <variable> - The variable that is to be tested in the body of
  1851. *                   the switch statement.
  1852. *      <const value> - Any constant expression that evaluates to an
  1853. *                      integer number.  If the <variable> is equal
  1854. *                      to this number, then the statement sequence
  1855. *                      directly after is executed.  const value may
  1856. *                      not contain any variables.
  1857. *      <statement sequence> - The single statement or block of
  1858. *                             statements which is/are to be executed. 
  1859. *
  1860. *   RESULT
  1861. *      none.
  1862. *
  1863. *   EXAMPLE
  1864. *      #include <stdio.h>
  1865. *
  1866. *      int main(void)
  1867. *      {
  1868. *         int x = 2;
  1869. *
  1870. *         switch (x)
  1871. *         {
  1872. *            case 1:
  1873. *               printf("1\n");
  1874. *               break;
  1875. *            case 2:
  1876. *               printf("2\n");
  1877. *               break;
  1878. *            default:
  1879. *               printf("3\n");
  1880. *         }
  1881. *         return 0;
  1882. *      }
  1883. *
  1884. *   NOTES
  1885. *      Switch is often used when the user is supposed to select
  1886. *      one of several options.  Menu programs, and similar progs
  1887. *      that prompt for user input can benefit from the use of
  1888. *      switches.  Also, remember, switch only works with integral
  1889. *      types.  This could be a char, int or enumeration.
  1890. *
  1891. *   BUGS
  1892. *      none.
  1893. *   SEE ALSO
  1894. *      case, break, default, int, enum,
  1895. *      if, else.
  1896. *
  1897. *********************************************************************/
  1898.  
  1899. /****** /typedef *****************************************************
  1900. *
  1901. *   NAME
  1902. *      typedef - Is a C keyword for creating an alias for data types.
  1903. *
  1904. *   SYNOPSIS
  1905. *      typedef <old name> <new name>;
  1906. *
  1907. *   FUNCTION
  1908. *      Typedef is a C keyword for creating an alias for data types.
  1909. *      Typedef can be used to substitute your own names for variable
  1910. *      types, like typedef unsigned char byte;.  Also you can use it
  1911. *      to abbreviate long type definitions so their not such a pain to
  1912. *      type.
  1913. *
  1914. *   INPUTS
  1915. *      <old name> - This is the old data type name.  It can be made up
  1916. *                   of several names, like unsigned char or
  1917. *                   struct test.
  1918. *      <new name> - This is the alias of the data type.  This
  1919. *                   can't contain any spaces as C assumes the last
  1920. *                   word in a typedef statement is the alias.  Also
  1921. *                   it should be noted that you may specify that the
  1922. *                   new type should inherently an array or pointer or
  1923. *                   something, (i.e., typedef char strtype[257]; or
  1924. *                   typedef int *intptr;).
  1925. *
  1926. *   RESULT
  1927. *      none.                                  
  1928. *
  1929. *   EXAMPLE
  1930. *      typedef char strtype[257];
  1931. *      typedef int *intptr;
  1932. *      typedef struct
  1933. *      {
  1934. *         strtype str;                                    
  1935. *         int x, y, z;
  1936. *      } structtype;
  1937. *      
  1938. *   NOTES
  1939. *      The last part of the example is a little ambiguous and deserves
  1940. *      some explanation.  In a normal struct definition, any name that
  1941. *      follows the closing bracket is the name of a global variable
  1942. *      that you are declaring.  In this instance typedef is saying to
  1943. *      replace structtype with the whole struct definition.  To
  1944. *      demonstrate what I'm talking about, try compiling the following
  1945. *      example.
  1946. *      #include <stdio.h>
  1947. *      #include <string.h>
  1948. *
  1949. *      int main(void)
  1950. *      {
  1951. *         struct {int x, y, z; char str[257];} hello;
  1952. *
  1953. *         strcpy(hello.str, "Hello There\n");
  1954. *
  1955. *         printf("%s\n", hello.str);
  1956. *
  1957. *         return 0;
  1958. *      }
  1959. *      In this code fragment, hello is a variable, and the part that
  1960. *      says struct {int x, y, z; char str[257];} IS the data type.
  1961. *      you are basically assigning the variable hello a unique data
  1962. *      type that can't be assigned anywhere else unless of course you
  1963. *      were to re-specify the struct from scratch.  
  1964. *
  1965. *   BUGS
  1966. *      none.
  1967. *   SEE ALSO
  1968. *      struct, union, enum, void, int, char, float, double.
  1969. *                                                              
  1970. *********************************************************************/
  1971.  
  1972. /****** /union *******************************************************
  1973. *
  1974. *   NAME
  1975. *      union - Similar to struct, but specifies that it's data members
  1976. *              are to occupy the same area of memory.
  1977. *
  1978. *   SYNOPSIS
  1979. *      union <type name>
  1980. *      {
  1981. *         <variable declarations>;
  1982. *      } <global variable list>;
  1983. *
  1984. *   FUNCTION
  1985. *      Union is similar to struct, but specifies that it's data
  1986. *      members are to occupy the same area of memory.  So, if you
  1987. *      specified a union (union test {int x; char c;} ;) then
  1988. *      any data assigned to c is also assigned to the low order
  1989. *      bits of x, and any value assigned to x can also be accessed
  1990. *      by c assuming that value is no larger than 8 bits in which
  1991. *      case the value returned by c is truncated.
  1992. *
  1993. *   INPUTS
  1994. *      <type name> - Is the name of the new type you are creating.
  1995. *                    Think of this as roughly corresponding to int,
  1996. *                    char, or float or the like with the exception
  1997. *                    that this is your own custom variable type.
  1998. *      <variable declarations> - Several lists of variable
  1999. *                                declarations which may be made up of
  2000. *                                any of C's built in types, or of
  2001. *                                other user defined (complex) types
  2002. *                                defined elsewhere.
  2003. *      <global variable list> - A list of variables of this newly
  2004. *                               defined type separated by commas.  Any
  2005. *                               variables declared here are considered
  2006. *                               global.  You may declare global
  2007. *                               variables of this type elsewhere but
  2008. *                               it is considered proper to do it here.
  2009. *
  2010. *   RESULT
  2011. *      none.
  2012. *
  2013. *   EXAMPLE
  2014. *      #include <stdio.h>
  2015. *      #include <values.h>
  2016. *
  2017. *      union test
  2018. *      {
  2019. *         int x;
  2020. *         char c;
  2021. *      } ;
  2022. *      
  2023. *      int main(void)
  2024. *      {
  2025. *         union test aunion;
  2026. *      
  2027. *         aunion.x = MAXINT;
  2028. *      
  2029. *         printf("%d\n", aunion.x);
  2030. *      
  2031. *         aunion.c = 'a';
  2032. *      
  2033. *         printf("%d\n", (int)aunion.c);
  2034. *         printf("%d\n", aunion.x);
  2035. *      
  2036. *         return 0;
  2037. *      }
  2038. *
  2039. *
  2040. *   NOTES
  2041. *      Unions only have a few very specialized applications in low
  2042. *      level programming.  For instance when writing the malloc
  2043. *      function, programmers generally use a union to control how the
  2044. *      memory is allocated.  For application programmers, (That's you
  2045. *      and me), I can't off hand think of any situation that would
  2046. *      warrant the use of a union.
  2047. *
  2048. *   BUGS
  2049. *      none.
  2050. *
  2051. *   SEE ALSO
  2052. *      struct, enum, typedef, void, int, char, float, double.
  2053. *
  2054. *********************************************************************/
  2055.  
  2056. /****** /unsigned ****************************************************
  2057. *
  2058. *   NAME
  2059. *      unsigned - Is an access modifier which may be used on either
  2060. *                 character or integer data types.
  2061. *
  2062. *   SYNOPSIS
  2063. *      unsigned <data type> <variable list>;
  2064. *
  2065. *   FUNCTION
  2066. *      Unsigned is an access modifier which may be used on either
  2067. *      character or integer data types.  Unsigned is used mainly
  2068. *      to extend the maximum value an integer, (or other integral
  2069. *      type), may hold.  (An integral type is any built in,
  2070. *      non-floating point, type.  Definitely not complex types.)
  2071. *
  2072. *   INPUTS
  2073. *      <data type> - In this case either char or int.
  2074. *      <variable list> - A list of variables to be declared separated
  2075. *                        by commas.
  2076. *
  2077. *   RESULT
  2078. *      none.
  2079. *
  2080. *   EXAMPLE
  2081. *      unsigned int x, y = 40000;
  2082. *      printf("%d\n", y);
  2083. *
  2084. *   NOTES
  2085. *      Normally an integer value is 16 bits long, translating into
  2086. *      any number between -32767 and 32767.  Making an int unsigned
  2087. *      will effectively change the range to 0 through 65,??? basically
  2088. *      doubling highest possible positive integer.  This can be
  2089. *      useful when you need numbers slightly higher than 32767 but
  2090. *      don't need to store any negative values, like in a loop
  2091. *      counter or something.
  2092. *
  2093. *   BUGS
  2094. *      none.
  2095. *
  2096. *   SEE ALSO
  2097. *      signed,
  2098. *
  2099. *      void, int, char, float, double.
  2100. *
  2101. *      long, short, const, volatile,
  2102. *      extern, static, register, auto,
  2103. *      struct, union, typedef, enum.
  2104. *
  2105. *********************************************************************/
  2106.  
  2107. /****** /void ********************************************************
  2108. *
  2109. *   NAME
  2110. *      void - Used to specify that a function doesn't return any
  2111. *             return values, or can declare void pointers which
  2112. *             can hold a pointer of any type.
  2113. *
  2114. *   SYNOPSIS
  2115. *      void <function name>();
  2116. *         or
  2117. *      void *<var or func name>;
  2118. *
  2119. *   FUNCTION
  2120. *      Void is used to specify that a function doesn't return any
  2121. *      return values, or can declare void pointers which
  2122. *      may be cast into any other ptr type without explicit casting.
  2123. *      note that C++ is a little more strict about using a void
  2124. *      ptr as an implicit cast and you may have to go ahead and
  2125. *      cast it explicitly if your using a C++ compiler.
  2126. *
  2127. *   INPUTS
  2128. *      <function name> - Any valid function name which will have a
  2129. *                        void return type specifying that this
  2130. *                        function has no return type.
  2131. *      <var or func name> - If it is a variable name then you
  2132. *                           are specifying a void ptr variable type.
  2133. *                           if it is a function name then you
  2134. *                           are specifying a void ptr return type.
  2135. *                           A void ptr return type does not indicate
  2136. *                           no return value.  It specifies that the
  2137. *                           type of the pointer which is being
  2138. *                           returned is generic and may be any type.
  2139. *
  2140. *   RESULT
  2141. *      none.
  2142. *
  2143. *   EXAMPLE
  2144. *      #include <stdio.h>
  2145. *      #include <stdlib.h>
  2146. *
  2147. *      int main(void)
  2148. *      {
  2149. *         int *x;
  2150. *         x = malloc(sizeof(int));
  2151. *      
  2152. *         *x = 67;
  2153. *      
  2154. *         printf("%d\n", *x);
  2155. *      
  2156. *         return 0;
  2157. *      }
  2158. *
  2159. *   NOTES
  2160. *      In the example above, malloc returns a void ptr.  This
  2161. *      allows x to be assigned the value even though it is an
  2162. *      integer pointer.
  2163. *      In addition to all I've said so far, I think that void used as
  2164. *      a return type signifying no return type, was instituted by the
  2165. *      ANSI standard.  I believe they did it this way because of
  2166. *      some incompatibility with the previous syntax for defining
  2167. *      C functions in the Ritchie/Kernigan definition.  I think
  2168. *      they wanted to maintain compatibility with programs using the
  2169. *      older definitions, but needed to find a way to distinguish
  2170. *      between the two.  I don't know the details as I'm not very
  2171. *      familiar with that definition of C since it is quit old,
  2172. *      (at least a decade now).  A lot of old code uses it though
  2173. *      so it's useful to know the distinction.  You should use the
  2174. *      new syntax though as it allows better type checking by the
  2175. *      compiler, and on top of that I recommend always declaring
  2176. *      return types even if the return type is int, because the
  2177. *      latest definition of C++ doesn't support implicit int
  2178. *      return types anymore.  "If your like me, you use C AND
  2179. *      C++ compilers to compile your C programs, (depending on the
  2180. *      tools you have available to you at the time), plus it's just
  2181. *      a good idea to make your C programs compatible with C++
  2182. *      just in case you ever want to go to it later.  You might
  2183. *      want to mix your old routines with your new code or something.
  2184. *
  2185. *   BUGS
  2186. *      none.
  2187. *
  2188. *   SEE ALSO
  2189. *      signed,
  2190. *
  2191. *      void, int, char, float, double.
  2192. *
  2193. *      long, short, const, volatile,
  2194. *      extern, static, register, auto,
  2195. *      struct, union, typedef, enum.
  2196. *      
  2197. *
  2198. *********************************************************************/
  2199.  
  2200. /****** /volatile ****************************************************
  2201. *
  2202. *   NAME
  2203. *      volatile - Is an access modifier which specifies that a given
  2204. *                 variable may be altered by another program outside
  2205. *                 the current program's control and for the compiler
  2206. *                 to perform no optimizations that would cause an
  2207. *                 error should such an outside alteration happen.
  2208. *
  2209. *   SYNOPSIS
  2210. *      volatile <data type> <variable list>;
  2211. *
  2212. *   FUNCTION
  2213. *      Volatile is an access modifier which specifies that a given
  2214. *      variable may be altered by another program outside the current
  2215. *      program's control and for the compiler to perform no
  2216. *      optimizations that would cause an error should such an outside
  2217. *      alteration happen.  Most frequently, this type of variable is
  2218. *      used when you want your program to access some fixed hardware
  2219. *      (or software) resource which is regulated by the OS and/or
  2220. *      other programs must access and/or change it.  A good example
  2221. *      of this is if you wanted to access the computer's clock
  2222. *      directly.  You'd assign a pointer to wherever the time info
  2223. *      is kept in the computer, and whenever you'd want to know
  2224. *      the time you could just take a look at that pointer.
  2225. *
  2226. *   INPUTS
  2227. *      <data type> - Any of C's built in types or your own user
  2228. *                    defined (complex) data type.
  2229. *      <variable list> - A list of variables being declared separated
  2230. *                        by commas.
  2231. *
  2232. *   RESULT
  2233. *      none.
  2234. *
  2235. *   EXAMPLE
  2236. *      volatile int x;
  2237. *
  2238. *   NOTES
  2239. *      Anytime one uses the volatile keyword, it denotes that your
  2240. *      getting pretty close to the system, IE pretty low level.  If
  2241. *      your trying to write portable software that will compile on
  2242. *      multiple platforms, (which should be the goal of every good
  2243. *      little programmer), it's not a good idea to start accessing
  2244. *      hardware, which may or may not exist on other platforms or
  2245. *      even later models of the same type of computer, (DOES AGA
  2246. *      RING ANY BELLS HERE).  In closing, this keyword is best left
  2247. *      to system and compiler programmers.
  2248. *
  2249. *      PS, Don't take my word on this as gospel, I'm not very
  2250. *      familiar with volatile and it's uses.
  2251. *
  2252. *   BUGS
  2253. *      none.
  2254. *
  2255. *   SEE ALSO
  2256. *      const, extern, static, register, auto.
  2257. *
  2258. *********************************************************************/
  2259.  
  2260. /****** /while *******************************************************
  2261. *
  2262. *   NAME
  2263. *      while - Used to form a while loop, the most basic looping
  2264. *              structure in C.
  2265. *
  2266. *   SYNOPSIS
  2267. *      while (<condition>)
  2268. *      {
  2269. *         <statement sequence>;
  2270. *      }
  2271. *
  2272. *   FUNCTION
  2273. *     While is used to form a while loop, the most basic looping
  2274. *     structure in C.  While executes while the <condition> is true,
  2275. *     when the condition becomes false the loop exits.  The test
  2276. *     condition is evaluated first when you enter the loop and then
  2277. *     once every time the loop finishes a cycle.
  2278. *
  2279. *   INPUTS
  2280. *      <condition> - Any valid C expression that evaluates to either
  2281. *                    true of false.
  2282. *      <statement sequence> - The single statement or block of
  2283. *                             statements which is/are to be executed.
  2284. *
  2285. *   RESULT
  2286. *      none.
  2287. *
  2288. *   EXAMPLE
  2289. *      x = 0;
  2290. *      while (x<10)
  2291. *      {
  2292. *         x++;
  2293. *         printf("%d\n", x);
  2294. *      }
  2295. *
  2296. *   NOTES
  2297. *      While and do while differ only in that a do while evalutes it's
  2298. *      conditional statement after the first iteration and while
  2299. *      evaluates it's expression before the loop is executed.  This
  2300. *      distinction can have a profound effect on what happens if
  2301. *      one is unaware of the distinction, however the loops can
  2302. *      generally substitute each other with minor modification.
  2303. *
  2304. *   BUGS
  2305. *      none.
  2306. *
  2307. *   SEE ALSO
  2308. *      do, for, switch, break, continue, default, if, else.
  2309. *
  2310. *********************************************************************/
  2311.